<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>hello vue 动画</title>
    <link rel="stylesheet" type="text/css" href="./lib/bootstrap/css/bootstrap.css">
    <link rel="stylesheet" href="./css/vue2-animate.css" type="text/css">

    <script type="text/javascript" src="./lib/vue/vue.js"></script>
    <script type="text/javascript" src="./lib/jquery/jquery.min.js"></script>
    <script type="text/javascript" src="./lib/bootstrap/js/bootstrap.js"></script>
    <style>
        #bgDiv {
            background-color: red;
            width: 100px;
            height: 100px;
        }

    </style>
</head>

<body>
    <div class="container" id="box">
        <nav class="nav nav-inline">
            <a class="nav-link active" href="https://cn.vuejs.org/v2/guide/">Vue Guide</a>
            <a class="nav-link" href="https://cn.vuejs.org/v2/api/">Vue Api</a>
            <a class="nav-link disabled" href="https://cn.vuejs.org/v2/examples/">Vue Examples</a>
        </nav>

        <div class="row">
            <button type="button" class="btn btn-primary" @click="toggle">Button</button>
            <span>{{message}}</span>
        </div>

        <!-- 
            首先将要过渡的元素用transition包裹，并设置过渡的name，
            然后添加触发这个元素过渡的按钮（实际项目中不一定是按钮，任何能触发过渡组件的DOM操作的操作都可以） 
        -->
        <div class="row">
            <transition name="bounce" 
                c="bounceInLeft" leave-active-class="bounceOutRight">
                <div id="bgDiv" v-show="show"></div>
            </transition>
        </div>

    </div>


</body>


<script>
    var v = new Vue({
        el: '#box',
        data: {
            show: false,
            message: '我隐藏了'
        },

        methods: {
            toggle() {
                this.show = !this.show;
                if (this.show) {
                    this.message = "我显示了";
                } else {
                    this.message = "我隐藏了";
                }
                console.log(this.show);
            }
        }
    });
</script>

</html>